package us.versus.them.b3ge.minigames.cards.poker;

import us.versus.them.b3ge.minigames.cards.Card;

class PokerHandEvaluation {
	public var score  : PokerHandScore;
	public var rank   : PokerHand;
	public var hand   : Array< Card >;

	public function new( hand:Array< Card > ) {
		this.hand = hand;
		this.score = null;
		this.rank = null;
	}

	public function evaluate() {
		this.hand.sort( Card.compare );
		var counts = PokerHandEvaluator.countValues( this.hand );
		this.rank   = PokerHandEvaluator.evaluateHand( this.hand, counts );
		this.score  = PokerHandEvaluator.scoreHand( this.rank, this.hand );
		return this;
	}

	public static inline function compare( a:PokerHandEvaluation, b:PokerHandEvaluation ) {
		return PokerHandScore.compare( a.score, b.score );
	}

}
